package com.zhiyou.brank.controller;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhiyou.brank.service.FlyClassService;
import com.zhiyou.brank.service.FlyGradService;
import com.zhiyou.brank.service.FlyScoreService;
import com.zhiyou.model.FYGrad;

import com.zhiyou.model.FyScore;
import com.zhiyou.utils.JsonResult;

@RestController
@RequestMapping("grad/")
public class FlyGradController {
@Autowired
FlyGradService flyGradService;//One查询班级各个同学单科成绩Two查询班级各科总平均分
@Autowired
FlyScoreService flyScoreService;
@Autowired
FlyClassService flyClassService;
@GetMapping(value="selectGradOne/{class_id}/{exam_id}")
	public JsonResult selectGradOne(@PathVariable("class_id")Integer class_id,@PathVariable("exam_id")Integer exam_id,HttpServletRequest req,HttpServletResponse rep){
//班级人数 学生id		
		return new JsonResult(flyGradService.selectGradOne(class_id, exam_id),"查询成功");		
	}
//平均分
@GetMapping(value="selectGradOneTwo/{class_id}/{exam_id}")
public JsonResult selectGradOneTwo(@PathVariable("class_id")Integer class_id,@PathVariable("exam_id")Integer exam_id,HttpServletRequest req,HttpServletResponse rep){		
	List<FyScore> fyscore=flyScoreService.selectScoreThree(class_id);
	List<FYGrad> fygead=new ArrayList<FYGrad>();
	for (int i = 0; i < fyscore.size(); i++) {
		//循环遍历科目id
		fygead.add(flyGradService.selectGradTwo(class_id, exam_id, fyscore.get(i).getCourse_id()));		
	}
	return new JsonResult(fygead,"查询成功");		
}
} 
